<?php
declare (strict_types=1);


namespace app\admin\controller;

use app\common\controller\Admin;

class Upload extends Admin
{
    public function upload()
    {
        // 获取表单上传文件 例如上传了001.jpg
        $file = $this->request->file('upload');
        // 上传到本地服务器
        $savename = \think\facade\Filesystem::putFile( 'topic', $file);
        return json([
            'code' => 0,
            'msg' => '上传成功',
            'data' => [
                'src' => '/uploads/' .  str_replace(DIRECTORY_SEPARATOR, '/', $savename)
            ]
        ]);
    }
}